(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('apf.popup.discount.viewAssetRepaymentController', viewAssetRepaymentController);
	viewAssetRepaymentController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'ajaxServiceFactory', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig', 'validatorConfig', 'authService' ];
	function viewAssetRepaymentController($scope, $q, $uibModalInstance, Constants, ajaxServiceFactory, dialogsModule, gridService, modalService, layoutConfig, validatorConfig, authService) {
		var ctrl = this;
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.assetrepayment = {};
		
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			var ajaxServices = ajaxServiceFactory.buildAjaxService({
				getAssetRepaymentViewOptions: {
					url: 'do/apf/dataList/getAssetRepaymentViewOptions',
					method: 'get'
				}
			});	
			
			function getAssetRepaymentViewOptions() {
				var defer = $q.defer();
				ajaxServices.getAssetRepaymentViewOptions().then(function(response) {
					ctrl.assetRepaymentStatusOptions = response.data.assetRepaymentStatus;
				});
				return defer.promise;
			}
		
			getAssetRepaymentViewOptions();
			
			authService.view(ctrl.dialogsModule.params).then(function(response) {
				if(response.data){
					ctrl.assetrepayment = response.data;
				}
			});
			
		};
	}
})(angular);
